package edu.calpoly.csc.coursebook.business.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

public class Course implements Serializable
{
   private String code;
   private String title;
   private String description;
   private int units;
   private int relevancyScore;
   
   private HashMap<String, Double> keywords;
   private List<String> interests;
   private List<String> geareas;
   
   public Course()
   {
      keywords = new HashMap<String, Double>();
      geareas = new ArrayList<String>();
      interests = new ArrayList<String>();
   }
   
   public int getRelevancyScore()
   {
      return relevancyScore;
   }

   public void setRelevancyScore(int relevancyScore)
   {
      this.relevancyScore = relevancyScore;
   }

   public String getCode()
   {
      return code;
   }
   public void setCode(String code)
   {
      this.code = code;
   }
   public String getDescription()
   {
      return description;
   }
   public void setDescription(String description)
   {
      this.description = description;
   }
   public String getTitle()
   {
      return title;
   }
   public void setTitle(String title)
   {
      this.title = title;
   }
   public int getUnits()
   {
      return units;
   }
   public void setUnits(int units)
   {
      this.units = units;
   }
   public HashMap<String, Double> getKeywords()
   {
      return this.keywords;
   }
   public List<String> getGeAreas()
   {
      return this.geareas;
   }
   public void addKeyword(String keyword, double relevance)
   {
      this.keywords.put(keyword, new Double(relevance));
   }
   public void addGeArea(String area)
   {
      this.geareas.add(area);
   }
   public void removeKeyword(String keyword)
   {
      this.keywords.remove(keyword);
   }
   public void removeGeArea(String area)
   {
      this.geareas.remove(area);
   }
   /** how many friends have taken this course? set this field after the 
     * algorithm runs */
   public int getFriendsTaken()
   {
      return -1;
   }
   public String getCourseIDString() {
	   String newTitle = this.title.replaceAll(" ", "");
	   StringBuffer keywordStr = new StringBuffer(newTitle + "::kw:");
	   int count = 0, size = this.interests.size();
	   
	   for (String str : this.interests) {
		   keywordStr.append(str);
		   if (count < size-1)
			   keywordStr.append("_");
		   count++;
	   }
	   
	   return keywordStr.toString();
   }
   public List<String> getInterests() { 
	   return this.interests;
   }
   public void addInterest(String interest) {
	   if (!this.interests.contains(interest))
		   this.interests.add(interest);
   }
   public void removeInterest(String interest) {
	   this.interests.remove(interest);
   }
}
